<?php

namespace app\backend\validate;

use think\Validate;

class ProductValidate extends Validate
{
    protected $rule = [
        'page' => 'integer',
        'limit' => 'integer',
        'id' => 'require|integer',
        'product_name' => 'require',
        'product_name_en' => 'require',
        'sale' => 'require',
        'cate_id' => 'require|integer',
        'sort' => 'integer',
        'time' => 'require',
        'scale' => 'require'
    ];

    protected $message = [
        'page.integer' => '页码格式错误',
        'limit.integer' => '条数格式错误',
        'id.require' => 'ID不能为空',
        'id.integer' => 'ID格式错误',
        'product_name.require' => '产品名称不能为空',
        'product_name_en.require' => '产品英文名称不能为空',
        'sale.require' => '售价不能为空',
        'cate_id.require' => '分类不能为空',
        'cate_id.integer' => '分类格式错误',
        'sort.integer' => '排序格式错误',
        'point_low.require' => '最低波动值不能为空',
        'point_high.require' => '最高波动值不能为空',
        'time.require' => '时间玩法间隔不能为空',
        'scale.require' => '盈亏比例不能为空'
    ];

    protected $scene = [
        'index' => ['page','limit'],
        'add' => ['product_name','product_name_en','sale','cate_id','sort','point_low','point_high','time','scale'],
        'edit' => ['id','product_name','product_name_en','sale','cate_id','sort','point_low','point_high','time','scale'],
        'del' => ['id']
    ];
}
